<template>
  <div class="hello">
    <el-button @click="showDialog" size="medium">显示</el-button>
    <el-dialog
      title="提示"
      :visible.sync="dialogStatus"
      width="60%"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <el-table :data="tableData" style="width: 100%" @select="getSelectList">
        <el-table-column type="selection" width="60" align="center">
        </el-table-column>
        <el-table-column prop="baseid" label="展示类型" width="180" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.type.length > 2">A</span>
            <span v-if="scope.row.type.length > 1">B</span>
          </template>
        </el-table-column>
        <el-table-column prop="baseid" label="BASID" width="180" align="center">
          <template slot-scope="scope">
            <el-input size="mini" v-model="scope.row.basid"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="samNo" label="样本编号" width="180" align="center">
          <template slot-scope="scope">
            <el-input size="mini" v-model="scope.row.samNo"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="note" label="备注" width="180" align="center">
          <template slot-scope="scope">
             <el-input size="mini" v-model="scope.row.note"></el-input>
          </template>
        </el-table-column>
      </el-table>
      <div class="btnArea">
        <el-button size="mini" @click="copyList">复制</el-button>
        <el-button size="mini" type="primary" @click="addNewItem">新增</el-button>
        <el-button size="mini" type="danger">删除</el-button>
        <el-button size="mini">取消</el-button>
        <el-button size="mini" type="success">保存</el-button>
        <el-button size="mini" type="warning">入库</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  data () {
    return {
      dialogStatus: false,
      // 表格数据
      tableData: [],
      nowSelectList: []
    }
  },
  methods: {
    showDialog () {
      this.dialogStatus = true
    },
    addNewItem () {
      this.tableData.push({
        type: [1, 2],
        basid: '20221118',
        samNo: '0001',
        note: ''
      })
    },
    getSelectList (selectList) {
      this.nowSelectList = selectList
    },
    copyList () {
      console.log('???')
      const newList = JSON.parse(JSON.stringify(this.nowSelectList))
      console.log('zzz', newList)
      this.tableData.concat(...this.tableData, ...newList)
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.btnArea {
  display: flex;
  justify-content: space-around;
  padding: 0 10%;
  margin-top: 10px;
  align-items:center;
}
</style>
